﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Modules/MasterPage/Main_Master.Master" AutoEventWireup="true" CodeBehind="Customer.aspx.cs" Inherits="ERB.Modules.CRM.Customer" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cpBreadcrumb" runat="server">
    <uc:Breadcrumb ID="ucBreadcrumb" runat="server" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" runat="server">
    <script type="text/javascript">
        function Import() {
            popupFileManager.Show();
        }
        function New() {
            popupPotential.Show();
            cpLoadData.PerformCallback();
            $("#hfAction").val("Insert");
        }

        function Edit(s, e) {
            var id = AspxGV1.GetRowKey(AspxGV1.GetFocusedRowIndex());
            popupPotential.Show();
            cpLoadData.PerformCallback();
            cpLoadData.PerformCallback('LoadDataEdit;' + id);
            $("#hfAction").val("Update");
            $("#hfID").val(id);
        }
        function Save() {
            var action = $("#hfAction").val();
            if (action == "Insert") {
                cpReloadGrid.PerformCallback('Insert');
            } else if (action == "Update") {
                cpReloadGrid.PerformCallback('Update');
            }
        }

        function SaveComplete(s, e) {
            var check = e.result;
            if (check == "Success") {
                popupPotential.Hide();
                LoadGrid.PerformCallback();
                $("#hfAction").val("");
            } else if (check == "SuccessAndNew") {
                New();
            } else if (check == "SuccessImport") {
                AspxGV1.PerformCallback();
            }
        }

        function SaveNew() {
            cpReloadGrid.PerformCallback('SaveNew');
        }
        function Exit() {
            popupPotential.Hide();
            LoadGrid.PerformCallback();
        }
        function LoadDistrict() {
            ReloadCbbDistrict.PerformCallback();
        }
        function LoadShipDistrict() {
            ReloadCbbShipDistrict.PerformCallback();
        }

        function imgURL() {
            return "../../uploads/"
        }

        function XuLyChuoi(string) {
            // string.substring(x) với x là chiều dài tên thư mục chứa hình ảnh .
            return string.substring(6);
        }
    </script>

    <asp:HiddenField ID="hfID" ClientIDMode="Static" runat="server" />
    <asp:HiddenField ID="hfAction" ClientIDMode="Static" runat="server" />
    <asp:HiddenField ID="hfExcel" runat="server" ClientIDMode="Static" />
    <uc:NavControl ID="NavControl" runat="server" addnewscript="function(s,e){New();}" editscript="function (s, e){Edit(s,e);}" delscript="True"/>
    <div class="contentMain">
        <dx:ASPxCallbackPanel ID="LoadGrid" ClientInstanceName="LoadGrid"
            runat="server" OnCallback="LoadGrid_Callback">
            <PanelCollection>
                <dx:PanelContent>
                    <dx:ASPxGridView ID="ASPxGridView1" runat="server" ClientInstanceName="AspxGV1" SkinID="Default"
                        AutoGenerateColumns="False" KeyFieldName="CustomerID" DataSourceID="dsCustomer"
                        OnCustomCallback="ASPxGridView1_CustomCallback">
                        <Columns>
                            <dx:GridViewCommandColumn ShowSelectCheckbox="True" Width="35px" ButtonType="Image">
                                <HeaderTemplate>
                                    <dx:ASPxCheckBox ID="ASPxCheckBox1" runat="server" ToolTip="Check All"
                                        CssPostfix="Aqua" CssFilePath="~/App_Themes/Aqua/{0}/styles.css">
                                        <ClientSideEvents CheckedChanged="function(s, e) {
	AspxGV1.SelectAllRowsOnPage(s.GetChecked());}" />
                                    </dx:ASPxCheckBox>
                                </HeaderTemplate>
                            </dx:GridViewCommandColumn>
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , CustomerNameMaster %>" FieldName="CustomerName" Width="130px" />
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , CustomerAddressMaster %>" FieldName="Address" Width="130px" />
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , CustomerWebsiteMaster %>" FieldName="Website" Width="130px" />
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , CustomerPhoneMaster %>" FieldName="Phone" />
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , CustomerFaxMaster %>" FieldName="Fax" />
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , CustomerMobileMaster %>" FieldName="Mobile" />
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , CustomerBankAccountMaster %>" FieldName="BankAccount" />
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , CustomerEmailMaster %>" FieldName="Email" />
                        </Columns>
                        <SettingsBehavior ColumnResizeMode="Control" />
                        <Settings ShowFilterRow="True"></Settings>
                    </dx:ASPxGridView>
                </dx:PanelContent>
            </PanelCollection>
        </dx:ASPxCallbackPanel>
        <asp:SqlDataSource ID="dsCustomer" runat="server" ConnectionString="<%$ ConnectionStrings:ProjectERBConnectionString %>"
            SelectCommand="sp_Customer_SelectAll" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:Parameter Name="BOID" Type="Int32" DefaultValue="1" />
            </SelectParameters>
        </asp:SqlDataSource>
    </div>

    <dx:ASPxPopupControl ID="popupFileManager" runat="server" ClientIDMode="AutoID" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
        CssPostfix="Aqua" SpriteCssFilePath="~/App_Themes/Aqua/{0}/sprite.css" Width="800px"
        ClientInstanceName="popupFileManager" HeaderText="<%$ Resources:Language , BOMManagementFileExcel %>" PopupHorizontalAlign="LeftSides"
        PopupVerticalAlign="Below" EnableClientSideAPI="True" PopupAction="None" PopupElementID="divPotential">
        <ContentCollection>
            <dx:PopupControlContentControl ID="PopupControlContentControl2" runat="server" SupportsDisabledAttribute="True">
                <dx:ASPxFileManager ID="ASPxFileManager1" runat="server">
                    <ClientSideEvents SelectedFileOpened="function(s, e) {
                        $('#hfExcel').val(XuLyChuoi(e.file.GetFullName()));
                         popupFileManager.Hide();
                        cpReloadGrid.PerformCallback('Import;'+XuLyChuoi(e.file.GetFullName()));
}" />
                    <Settings RootFolder="~/uploads/excel" ThumbnailFolder="~/Thumb/" AllowedFileExtensions=".xls,.xlsx" />
                    <SettingsEditing AllowDelete="True" AllowMove="True" AllowRename="True" />
                </dx:ASPxFileManager>
            </dx:PopupControlContentControl>
        </ContentCollection>
    </dx:ASPxPopupControl>

    <dx:ASPxPopupControl ID="popupPotential" runat="server" ClientIDMode="AutoID" Height="600px"
        Theme="PlasticBlue" Width="1000px" ClientInstanceName="popupPotential" HeaderText="<%$ Resources:Language , CustomerTitle %>"
        PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" EnableClientSideAPI="True"
        PopupAction="None" PopupElementID="divPotential" CloseAction="CloseButton" AllowDragging="True">
        <ContentStyle>
            <Paddings Padding="2px" />
            <Paddings Padding="2px"></Paddings>
        </ContentStyle>
        <ContentCollection>
            <dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server" SupportsDisabledAttribute="True">
                <div class="NavButtonRight">
                    <uc:NavControlDetail ID="ucNavControlDetail" runat="server" savescript="function(s,e){Save();}" savenewscript="function (s, e){SaveNew(); }"  closescript="function(s,e){Exit();}" />
                </div>
                <div>
                    <dx:ASPxCallbackPanel ID="cpLoadData" runat="server" ClientInstanceName="cpLoadData"
                        OnCallback="cpLoadData_Callback">
                        <ClientSideEvents EndCallback="function(s, e){SaveComplete();}" />
                        <PanelCollection>
                            <dx:PanelContent ID="PanelContent1" runat="server">
                                <table cellpadding="0" cellspacing="0" class="table_edit" width="100%">
                                    <tbody>
                                        <tr>
                                            <td>
                                                <table cellpadding="2" cellspacing="2" class="style1" width="100%">
                                                    <tr>
                                                        <td>
                                                            <asp:Panel ID="Panel_Address" runat="server" CssClass="ColapsePanel">
                                                                <dx:ASPxLabel ID="Label11" runat="server" Text="<%$ Resources:Language , CustomerInfomation %>">
                                                                </dx:ASPxLabel>
                                                            </asp:Panel>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style3" valign="top">
                                                <table cellpadding="0" cellspacing="0" class="tblFormView" width="100%">
                                                    <tr>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label12" runat="server" Text="<%$ Resources:Language , CustomerName %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxTextBox ID="txtCustomerName" runat="server" Width="90%" SkinID="requireField"
                                                                TabIndex="1">
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label18" runat="server" Text="<%$ Resources:Language , CustomerPaymentMethod %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxComboBox ID="CboTerm" runat="server" Width="90%" TextField="Description"
                                                                ValueField="Termscode" TabIndex="2" SkinID="cmbrequireField">
                                                            </dx:ASPxComboBox>
                                                            <%--<asp:SqlDataSource ID="dsTerm" runat="server" ConnectionString="<%$ ConnectionStrings:ChiThanhCo_ConnectionString %>"
                                                                SelectCommand="TblTerms_Terms" SelectCommandType="StoredProcedure"></asp:SqlDataSource>--%>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label15" runat="server" Text="<%$ Resources:Language , CustomerBank %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxTextBox ID="txtBank" runat="server" Width="90%" TabIndex="3">
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label16" runat="server" Text="<%$ Resources:Language , CustomerBankAccount %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxSpinEdit ID="txtBankAcount" runat="server" Width="90%" TabIndex="4" MaxLength="15" SpinButtons-ShowIncrementButtons="false">
                                                            </dx:ASPxSpinEdit>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="ASPxLabel1" runat="server" Text="<%$ Resources:Language , CustomerAddress %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td colspan="3" style="width: 75% !important" class="tblFormViewtdValue">
                                                            <dx:ASPxTextBox ID="txtAddress" runat="server" Width="90%" TabIndex="5" SkinID="requireField">
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <table cellpadding="2" class="style1" width="100%">
                                                    <tr>
                                                        <td>
                                                            <asp:Panel ID="Panel2" runat="server" CssClass="ColapsePanel">
                                                                <dx:ASPxLabel ID="Label24" runat="server" Text="<%$ Resources:Language , CustomerContact %>">
                                                                </dx:ASPxLabel>
                                                            </asp:Panel>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right" class="style5" valign="top">
                                                <table cellpadding="0" cellspacing="0" class="tblFormView" width="100%">
                                                    <tr>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label25" runat="server" Text="<%$ Resources:Language , CustomerPhone %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxSpinEdit ID="txtPhone" runat="server" Width="90%" TabIndex="6" MaxLength="15" SpinButtons-ShowIncrementButtons="false">
                                                            </dx:ASPxSpinEdit>
                                                        </td>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label28" runat="server" Text="<%$ Resources:Language , CustomerContactName %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxTextBox ID="txtContact" runat="server" Width="90%" TabIndex="7" SkinID="requireField">
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label26" runat="server" Text="<%$ Resources:Language , CustomerMobile %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxSpinEdit ID="txtMobile" runat="server" Width="90%" TabIndex="8" MaxLength="15" SpinButtons-ShowIncrementButtons="false">
                                                            </dx:ASPxSpinEdit>
                                                        </td>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label29" runat="server" Text="<%$ Resources:Language , CustomerEmail %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxTextBox ID="txtEmail" runat="server" Width="90%" TabIndex="9" SkinID="emailField">
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label27" runat="server" Text="<%$ Resources:Language , CustomerFax %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxSpinEdit ID="txtFax" runat="server" Width="90%" TabIndex="10" MaxLength="15" SpinButtons-ShowIncrementButtons="false">
                                                            </dx:ASPxSpinEdit>
                                                        </td>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label30" runat="server" Text="<%$ Resources:Language , CustomerWebsite %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxTextBox ID="txtWebsite" runat="server" Width="90%" TabIndex="11">
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <table cellpadding="2" class="style1" width="100%">
                                                    <tr>
                                                        <td>
                                                            <asp:Panel ID="Panel3" runat="server" CssClass="ColapsePanel">
                                                                <dx:ASPxLabel ID="Label3" runat="server" Text="<%$ Resources:Language , CustomerOtherInfomation %>">
                                                                </dx:ASPxLabel>
                                                            </asp:Panel>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style6" valign="top">
                                                <table cellpadding="0" cellspacing="0" class="tblFormView" width="100%">
                                                    <tr>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label20" runat="server" Text="<%$ Resources:Language , CustomerCreateDate %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxTextBox ID="txtDateCreate" runat="server" Enabled="False">
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label35" runat="server" Text="<%$ Resources:Language , CustomerTaxCode %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxSpinEdit ID="txtTaxCode" runat="server" Width="90%" TabIndex="12" MaxLength="12" SpinButtons-ShowIncrementButtons="false">
                                                            </dx:ASPxSpinEdit>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label34" runat="server" Text="<%$ Resources:Language , CustomerDiscontinue %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxCheckBox ID="chkonhold" runat="server" TabIndex="13" />
                                                        </td>
                                                        <td class="tblFormViewtdLabel"></td>
                                                        <td class="tblFormViewtdValue"></td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </dx:PanelContent>
                        </PanelCollection>
                    </dx:ASPxCallbackPanel>
                </div>
            </dx:PopupControlContentControl>
        </ContentCollection>
    </dx:ASPxPopupControl>

    <dx:ASPxCallback ID="cpReloadGrid" ClientInstanceName="cpReloadGrid" runat="server"
        OnCallback="cpReloadGrid_Callback">
        <ClientSideEvents CallbackComplete="function(s,e){SaveComplete(s,e);}" />
    </dx:ASPxCallback>
</asp:Content>
